<!-- 设备参数 -->
<template>
  <div class="dashboard-editor-container" style="min-width:1150px">
    <el-row style="background: #fff; padding: 16px 16px 0; margin-bottom: 32px">
      <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
        <el-button slot="append" @click="submit">保存设置</el-button>
        <el-tab-pane key="系统参数" label="系统参数" name="系统参数" lazy>
          <div class="btn topSubmitBtn" style="width:530px">
            <el-button type="primary" @click="submit()">保存设置</el-button>
          </div>
          <div class="input-item"> 
            <el-form :model="deviceform"  label-width="180px">
              <div class="parameType-wrap">
                <div class="parameType">
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="日志默认显示天数:">
                    <el-input v-model.trim="deviceform.default_log_days" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="4"><span slot="append">天</span></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="日志分页默认显示条数:">
                    <el-select v-model="deviceform.page_length" style="width:100%;">
                      <el-option label="10条/页" value=10></el-option>
                      <el-option label="20条/页" value=20></el-option>
                      <el-option label="30条/页" value=30></el-option>
                      <el-option label="40条/页" value=40></el-option>
                      <el-option label="50条/页" value=50></el-option>
                      <el-option label="100条/页" value=100></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="前端自动注销时长:">
                    <el-select v-model="deviceform.ui_logout_interval" style="width:100%;">
                      <el-option label="不自动注销" value=0></el-option>
                      <el-option label="5分钟" value=300></el-option>
                      <el-option label="10分钟" value=600></el-option>
                      <el-option label="15分钟" value=900></el-option>
                      <el-option label="30分钟" value=1800></el-option>
                      <el-option label="60分钟" value=3600></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <!-- <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="僵尸连接超时:">
                    <el-input v-model="deviceform.mainrsa_connect_zombie_timeout" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="9"><span slot="append">秒</span></el-input>
                  </el-form-item>
                </el-col> -->
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="最近性能日志缓存时长:">
                    <el-input v-model.trim="deviceform.cach_log_save_seconds" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">天</span></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="资产信息同步周期:">
                    <el-input v-model.trim="deviceform.sync_device_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="5"><span slot="append">秒</span></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="校区上送状态周期:">
                    <el-input v-model.trim="deviceform.report_device_status_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="5"><span slot="append">秒</span></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="校区网络心跳周期:">
                    <el-input v-model.trim="deviceform.echo_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="5"><span slot="append">秒</span></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="日志上送窗口时长:">
                    <el-input v-model.trim="deviceform.report_log_window_days" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="4"><span slot="append">天</span></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="网络状态检测间隔:">
                    <el-input v-model.trim="deviceform.check_net_status_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="5"><span slot="append">秒</span></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="校区刷新配置参数间隔:">
                    <el-input v-model.trim="deviceform.refresh_param_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="5"><span slot="append">秒</span></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="根节点名称:" prop="root_corp_name" :rules="[{ required: true, message: '请输入根节点名称', trigger: 'blur' }]">
                    <el-input v-model.trim="deviceform.root_corp_name" maxlength="64"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="数据备份机制:">
                    <el-checkbox true-label="1" false-label="0" v-model="deviceform.is_start_cfg_backup">备份配置文件</el-checkbox>
                    <el-checkbox true-label="1" false-label="0" v-model="deviceform.is_start_database_backup">备份数据库</el-checkbox>
                  </el-form-item>
                </el-col>
                </div>
              </div>
            </el-form>
          </div>
        </el-tab-pane>
        <el-tab-pane key="性能阈值" label="性能阈值" name="性能阈值" lazy>
          <div class="btn topSubmitBtn" style="width:530px">
            <el-button type="primary" @click="submit()">保存设置</el-button>
          </div>
          <div class="input-item"> 
            <el-form :model="deviceform"  label-width="150px">
              <div class="parameType-wrap">
                <div class="parameType">
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="资产性能自检周期:">
                      <el-input v-model.trim="deviceform.check_dcd_perf_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="5"><span slot="append">秒</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="12" :sm="12" :lg="12">
                    <el-form-item label="CPU使用率连续:">
                      <el-input style="width:150px" v-model.trim="deviceform.dcd_max_cpu_keep_times" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="9"><span slot="append">次</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="12" :sm="12" :lg="12">
                    <el-form-item label="，超过:" label-width="120px">
                      <el-input v-model.trim="deviceform.dcd_max_cpu_percent" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">%</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="12" :sm="12" :lg="12">
                    <el-form-item label="内存使用率连续:">
                      <el-input style="width:150px" v-model.trim="deviceform.dcd_max_mem_keep_times" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="9"><span slot="append">次</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="12" :sm="12" :lg="12">
                    <el-form-item label="，超过:" label-width="120px">
                      <el-input v-model.trim="deviceform.dcd_max_mem_percent" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">%</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="磁盘空间阈值:">
                      <el-input v-model.trim="deviceform.dcd_max_disk_percent" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">%</span></el-input>
                    </el-form-item>
                  </el-col>
                </div>
              </div>
            </el-form>
          </div>
        </el-tab-pane>
        <el-tab-pane key="数据处理" label="数据处理" name="数据处理" lazy>
          <div class="btn topSubmitBtn" style="width:650px">
            <el-button type="primary" @click="submit()">保存设置</el-button>
          </div>
          <div class="input-item"> 
            <el-form :model="deviceform"  label-width="180px">
              <div class="parameType-wrap">
                <div class="parameType" style="width:650px">
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="执行日志数据处理时间点:">
                      <el-select v-model="deviceform.AutoDelHours" style="width:100%;">
                        <!-- <el-option label="不执行数据处理" :value="0"></el-option> -->
                        <el-option v-for="item in 23" :key="item" :label="item + ':00'" :value="item"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="14" :sm="14" :lg="14">
                    <el-form-item label="日志储存天数:">
                      <el-input v-model.trim="deviceform.LogSaveDays" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="4" :disabled="deviceform.AutoDelHours === 0"><span slot="append">天</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="10" :sm="10" :lg="10" style="margin-top:10px;"><span style="color:#aaa">(填0表示不执行数据自动删除)</span></el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="最近执行时间:">
                      <el-input v-model="deviceform.LastActTime" disabled oninput="value=value.replace(/[^0-9]/g,'')" maxlength="9"></el-input>
                    </el-form-item>
                  </el-col>
                </div>
              </div>
            </el-form>
          </div>
        </el-tab-pane>
        <el-tab-pane key="首页参数" label="首页参数" name="首页参数" lazy>
          <div class="btn topSubmitBtn" style="width:530px">
            <el-button type="primary" @click="submitHomePage()">保存设置</el-button>
          </div>
          <div class="input-item"> 
            <el-form :model="deviceform"  label-width="130px">
              <div class="parameType-wrap">
                <div class="parameType">
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="活动进程最近:">
                      <el-input v-model.trim="deviceform.processDays" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="4"><span slot="append">天</span></el-input>
                    </el-form-item>
                    <el-form-item label="事件日志最近:">
                      <el-input v-model.trim="deviceform.EventLogDays" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="4"><span slot="append">天</span></el-input>
                    </el-form-item>
                    <el-form-item label="自动刷新间隔:">
                      <el-input v-model.trim="deviceform.AutomaticRefreshInterval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="5"><span slot="append">秒</span></el-input>
                    </el-form-item>
                    <el-form-item label="最大事件条数:">
                      <el-input v-model.trim="deviceform.EventLogTotal" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="9"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="事件严重性等级:">
                      <el-select v-model="deviceform.EventLevel" style="width:100%;">
                        <el-option label="全部" :value="0"></el-option>
                        <el-option label="紧急" :value="1"></el-option>
                        <el-option label="重要" :value="2"></el-option>
                        <el-option label="默认" :value="3"></el-option>
                        <el-option label="普通" :value="4"></el-option>
                        <el-option label="告知" :value="5"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </div>
              </div>
            </el-form>
          </div>
        </el-tab-pane>
        <el-tab-pane key="装置维护" label="装置维护" name="装置维护" lazy>
          <div class="btn topSubmitBtn" style="width:680px">
            <el-button type="primary" @click="submit()">保存设置</el-button>
          </div>
          <div class="input-item"> 
            <el-form :model="deviceform"  label-width="220px">
              <div class="parameType-wrap">
                <div class="parameType" style="width:680px">
                  <el-col :xs="16" :sm="16" :lg="16">
                    <el-form-item label="连续运行多长时间自动重启设备:">
                      <el-input v-model.trim="deviceform.reset_keep_run_seconds" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">天</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="8" :sm="8" :lg="8" style="margin-top:10px;"><span style="color:#aaa">(填0表示无效)</span></el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="每天指定时间自动重启设备:">
                      <el-select v-model="deviceform.reset_on_hours" style="width:100%;">
                        <el-option label="不执行定点自动重启" :value="0"></el-option>
                        <el-option v-for="item in 23" :key="item" :label="item + ':00'" :value="item"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <!-- <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="" label-width="60px">
                      <el-checkbox :true-label = 1 :false-label = 0 v-model="deviceform.is_start_n2n">开启网络维护透传服务，透传服务指令：</el-checkbox>
                      <el-input v-model="deviceform.maint_n2n_cmd"  maxlength="64" style="width:310px;margin-left:10px;"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="" label-width="60px">
                      <el-checkbox :true-label = 1 :false-label = 0 v-model="deviceform.is_check_eth0_switch">启用检测网口90秒内连续插拔超过3次，自动恢复地址为：</el-checkbox>
                      <el-input v-model="deviceform.restore_ip"  maxlength="64" style="width:204px;margin-left:10px;"></el-input>
                    </el-form-item>
                  </el-col> -->
                </div>
              </div>
            </el-form>
          </div>
        </el-tab-pane>
        <el-tab-pane key="终端参数" label="终端参数" name="终端参数" lazy>
          <div class="btn topSubmitBtn" style="width:650px">
            <el-button type="primary" @click="submit()">保存设置</el-button>
          </div>
          <div class="input-item"> 
            <el-form :model="deviceform"  label-width="220px">
              <div class="parameType-wrap">
                <div class="parameType" style="width:650px">
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="终端代理心跳间隔:">
                      <el-input v-model.trim="deviceform.agent_hand_shake_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="6"><span slot="append">秒</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="终端代理心跳超时次数:">
                      <el-input v-model.trim="deviceform.lost_hand_shake_times" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="6"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="终端代理网络连接检测间隔:">
                      <el-input v-model.trim="deviceform.check_agent_net_status_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="6"><span slot="append">秒</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="终端代理定时更新参数间隔:">
                      <el-input v-model.trim="deviceform.refresh_agent_param_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="6"><span slot="append">秒</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="终端代理自动升级检测间隔:">
                      <el-input v-model.trim="deviceform.agent_auto_upgrade_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="6"><span slot="append">秒</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="资产上送状态周期:">
                      <el-input v-model.trim="deviceform.report_device_status_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="6"><span slot="append">秒</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="客户端托盘显示控制:">
                      <el-radio v-model="deviceform.agent_show_trayicon" :label="1">显示</el-radio>
                      <el-radio v-model="deviceform.agent_show_trayicon" :label="0">隐藏</el-radio>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="客户端托盘显示控制退出菜单:">
                      <el-radio v-model="deviceform.agent_show_trayicon_exit" :label="1">显示</el-radio>
                      <el-radio v-model="deviceform.agent_show_trayicon_exit" :label="0">隐藏</el-radio>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="客户端托盘退出密码:">
                      <el-input v-model.trim="deviceform.agent_trayicon_exit_pwd" maxlength="36"></el-input>
                      <!-- <span style="color:#aaa">
                        （空表示不需要密码）
                      </span> -->
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="客户端托盘提示内容:">
                      <el-input v-model.trim="deviceform.agent_trayicon_tip" maxlength="36"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="安装软件检测间隔:">
                      <el-input v-model.trim="deviceform.check_install_app_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="6"><span slot="append">秒</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="硬件变化检测间隔:">
                      <el-input v-model.trim="deviceform.check_hardware_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="6"><span slot="append">秒</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="安全软件版本检测提醒模式:">
                      <el-radio v-model="deviceform.security_check_mode" :label="0">不检测</el-radio>
                      <el-radio v-model="deviceform.security_check_mode" :label="1">开机提醒一次</el-radio>
                      <el-radio v-model="deviceform.security_check_mode" :label="2">定期检测提醒</el-radio>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="" label-width="220px">
                      <el-input v-model.trim="deviceform.security_check_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="8" :disabled="deviceform.security_check_mode !== 2"><span slot="append">分钟</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="18" :sm="18" :lg="18">
                    <el-form-item label="杀毒软件最新版本:">
                      <el-input v-model="deviceform.king_soft_av_client_ver" maxlength="36"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="6" :sm="6" :lg="6">
                    <p style="color:#aaa;font-size:14px;line-height:10px">（填空表示不检测）</p>
                  </el-col>
                  <el-col :xs="18" :sm="18" :lg="18">
                    <el-form-item label="病毒库最新版本:">
                      <el-input v-model="deviceform.king_soft_av_db_ver" maxlength="36"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="6" :sm="6" :lg="6">
                    <p style="color:#aaa;font-size:14px;line-height:10px">（填空表示不检测）</p>
                  </el-col>
                  <el-col :xs="18" :sm="18" :lg="18">
                    <el-form-item label="零信任最新版本:">
                      <el-input v-model="deviceform.trust_cyber_ver" maxlength="36"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="6" :sm="6" :lg="6">
                    <p style="color:#aaa;font-size:14px;line-height:10px">（填空表示不检测）</p>
                  </el-col>
                </div>
              </div>
            </el-form>
          </div>
        </el-tab-pane>
        <el-tab-pane key="角色定义" label="角色定义" name="角色定义" lazy>
          <div class="btn topSubmitBtn" style="width:650px">
            <el-button type="primary" @click="addRole()">新增角色</el-button>
          </div>
          <el-table stripe border :data="tableData" style="width: 650px; margin-top: 15px" height="550">
            <el-table-column label="序号" width="80" type="index" :index='(index) => { return (index + 1) + (pageNum - 1) * pageSize }'> </el-table-column>
            <el-table-column label="角色" prop="Role"  show-overflow-tooltip></el-table-column>
            <el-table-column label="操作" width="120px"  fixed="right" >
              <template slot-scope="scope">
                <!-- <el-button type="primary" size="mini" @click="changeModer(scope.row)">修改</el-button> -->
                <el-button size="mini" type="danger" @click="deleteModer(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane key="管理中心" label="管理中心" name="管理中心" lazy>
          <div class="btn topSubmitBtn" style="width:650px">
            <el-button type="primary" @click="submit()">保存设置</el-button>
          </div>
          <div class="input-item"> 
            <el-form :model="deviceform"  label-width="220px">
              <div class="parameType-wrap">
                <div class="parameType" style="width:650px">
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="集中管理中心:">
                      <el-input v-model.trim="deviceform.center"  maxlength="64"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="12" :sm="12" :lg="12">
                    <el-form-item label="CPU使用率连续:">
                      <el-input style="width:150px" v-model.trim="deviceform.center_dcd_max_cpu_keep_times" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="9"><span slot="append">次</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="12" :sm="12" :lg="12">
                    <el-form-item label="，超过:" label-width="120px">
                      <el-input v-model.trim="deviceform.center_dcd_max_cpu_percent" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">%</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="12" :sm="12" :lg="12">
                    <el-form-item label="内存使用率连续:">
                      <el-input style="width:150px" v-model.trim="deviceform.center_dcd_max_mem_keep_times" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="9"><span slot="append">次</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="12" :sm="12" :lg="12">
                    <el-form-item label="，超过:" label-width="120px">
                      <el-input v-model.trim="deviceform.center_dcd_max_mem_percent" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">%</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="磁盘空间阈值:">
                      <el-input v-model.trim="deviceform.center_dcd_max_disk_percent" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">%</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="18" :sm="18" :lg="18">
                    <el-form-item label="连续运行多长时间自动重启设备:">
                      <el-input v-model.trim="deviceform.center_reset_keep_run_seconds" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">天</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="6" :sm="6" :lg="6">
                    <p style="color:#aaa;font-size:14px;line-height:10px;padding-left:5px;">(0表示不执行自动重启)</p>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="每天指定时间自动重启设备:">
                      <el-select v-model="deviceform.center_reset_on_hours" style="width:100%;">
                        <el-option label="不指定" value="0"></el-option>
                        <el-option v-for="item in 23" :key="item" :label="item + ':00'" :value="item"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </div>
              </div>
            </el-form>
          </div>
        </el-tab-pane>
        <el-tab-pane key="升级规则" label="升级规则" name="升级规则" lazy>
          <div class="btn topSubmitBtn" style="width:850px">
            <el-button type="primary" @click="submitUpgradeRules()">保存设置</el-button>
          </div>
          <div class="input-item"> 
            <el-form :model="deviceform"  label-width="120px">
              <div class="parameType-wrap">
                <div class="parameType" style="width:850px"> 
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="升级规则:">
                      <el-radio v-model="deviceform.UpgradeMode" :label="1">全部校区升级</el-radio>
                      <el-radio v-model="deviceform.UpgradeMode" :label="2">指定校区升级</el-radio>
                      <el-button type="primary" size="mini" :disabled="deviceform.UpgradeMode === 1" @click="choseSchool">选择校区</el-button>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="已选择校区:">
                      <el-input v-model="deviceform.choseSchoolList" type="textarea" :rows="6" disabled ></el-input>
                    </el-form-item>
                  </el-col>
                </div>
              </div>
            </el-form>
          </div>
        </el-tab-pane>
      </el-tabs>
    </el-row>
    
    <el-dialog 
      :close-on-click-modal="false" 
      :close-on-press-escape="false" 
      :title="Action === 1 ? `新增角色` : `修改角色`" 
      :visible.sync="moderVisible"
      v-el-drag-dialog  
      width="30%">
      <el-form label-width="120px" :model="partition" ref="partition">
        <el-form-item :label="`角色名称`" prop="Name">
          <el-input :placeholder="`请输入角色名称`" maxlength="10" v-model="partition.Role"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitRole()">确 定</el-button>
        <el-button type="info" @click="moderVisible = false">取 消</el-button>
      </span>
    </el-dialog>
    <el-dialog 
      :fullscreen="dialogFull"
      :close-on-click-modal="false" 
      :close-on-press-escape="false" 
      title="选择校区" 
      :visible.sync="choseSchoolDialog"
      v-el-drag-dialog  
      width="920px">
      <el-form label-width="120px" :model="partition" ref="partition">
        <el-form-item :label="`请选择校区`" prop="Name">
          <el-cascader-panel
            multiple 
            style="width:100%;" 
            placeholder="请选择校区："
            ref="cascaderAddr"
            v-model="partition.Object"
            clearable
            :options="DeviceObjList"
            :props="{ label: 'SubClass', value: 'value', emitPath: false, checkStrictly: false, multiple: true}"
            @change="handleChange">
          </el-cascader-panel>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitSchool()">确 定</el-button>
        <el-button type="info" @click="choseSchoolDialog = false">取 消</el-button>
      </span>
    </el-dialog>

  </div>
</template>

<script>
import Cookies from 'js-cookie'
import treeTransfer from 'el-tree-transfer'
import { connrequest } from "@/api/firstPage"
import { formatDuration, parseTime } from '@/utils/index'
import elDragDialog from "@/directive/el-drag-dialog"; 
export default {
  directives: { elDragDialog , treeTransfer},
  components: {
    treeTransfer
  },
  data() {
    return {
      Action: 1,
      pageNum: 1,
      pageSize: 10,
      moderVisible: false,
      choseSchoolDialog: false,
      editCascaderVisible: false,
      partition: {},
      tableData: [],
      DeviceObjList: [],
      activeName: '系统参数',
      deviceform:{
      },
      oldData:[],
      dialogFull:false,
      fromData: [], // 存储传输的数据
      toData:[],
      schoolMap:''

    }
  },
  //生命周期 - 创建完成（访问当前this实例）
  created() {
    this.getData()
  },
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {},
  methods: {
    async handleClick(tab){
      if(tab.label === '系统参数'){
        this.getData()
      }
      else if(tab.label === '性能阈值'){
        this.getData()
      }
      else if(tab.label === '数据处理'){
        this.getData()
      }
      else if(tab.label === '首页参数'){
        const res = await connrequest('GetFirstPageParam')
        this.deviceform = {...res.Data}
      }
      else if(tab.label === '装置维护'){
        this.getData()
        // const res = await connrequest('GetParamDevcieMaintCfg')
        // this.deviceform = {...res.Data, reset_keep_run_seconds: res.Data.reset_keep_run_seconds ?  res.Data.reset_keep_run_seconds / 60 : 0}
      }
      else if(tab.label === '终端参数'){
        this.getData()
      }
      else if(tab.label === '角色定义'){
        this.GetParamDictRole()
      }
      else if(tab.label === '管理中心'){
        this.getData()
      }else if(tab.label === '升级规则'){
        this.GetUpgradeRule()
        const res = await this.GetDeviceStatusSumTree()
        this.DeviceObjList = res
      }
    },
    async getData(){
      const res = await connrequest('GetParamThreshhold')
      const res1 = await connrequest('GetParamLogCfg')
      let obj = {}
      res.Data = res.Data || []
      res.Data.map( item  => {
        obj[item.Name] = item.Value
      })
      this.oldData = res.Data
      obj.center_reset_keep_run_seconds = obj.center_reset_keep_run_seconds ?  obj.center_reset_keep_run_seconds / 86400 : 0
      obj.reset_keep_run_seconds = obj.reset_keep_run_seconds ?  obj.reset_keep_run_seconds / 86400 : 0
      obj.cach_log_save_seconds = obj.cach_log_save_seconds / 3600 / 24
      obj.security_check_interval = obj.security_check_interval ? obj.security_check_interval / 60 : '',
      obj.UpgradeMode = obj.UpgradeMode ? obj.UpgradeMode : 1
      this.deviceform = {...obj, ...res1.Data, LastActTime: parseTime(res1.Data.LastActTime)}
    },
    async submit(){
      if(this.activeName === '系统参数' && this.deviceform.default_log_days < 1){
        this.$message.error('日志默认显示天数请设置最少为1天')
        return
      }
      if(this.activeName === '系统参数' && this.deviceform.cach_log_save_seconds < 1){
        this.$message.error('性能日志缓存时长请设置最少为1天')
        return
      }
      if(this.activeName === '终端参数' && this.deviceform.security_check_mode === 2 && !this.deviceform.security_check_interval){
        this.$message.error('请设置定期检测提醒时间')
        return
      }
      if(this.activeName === '终端参数'  && this.deviceform.security_check_mode === 2 && this.deviceform.security_check_interval < 1){
        this.$message.error('定期检测提醒时间最少为1分钟')
        return
      }
      // if(this.activeName === '数据处理' && this.deviceform.LogSaveDays < 1){
      //   this.$message.error('日志储存天数请设置最少为1天')
      //   return
      // }
      let newObj = {...this.deviceform}
      newObj.center_reset_keep_run_seconds = newObj.center_reset_keep_run_seconds * 3600 * 24
      newObj.reset_keep_run_seconds = newObj.reset_keep_run_seconds * 3600 * 24
      newObj.cach_log_save_seconds = newObj.cach_log_save_seconds * 3600 * 24
      newObj.security_check_interval = newObj.security_check_interval * 60
      this.oldData = this.oldData.map(item => {
        for (const key in newObj) {
          if(item.Name === key){
            item.Value = newObj[key]
          }
        }
        return item
      })
      const data = {
        Data: this.oldData,
      }
      const res = await connrequest('SetParamThreshhold', data)
      const data1 = {
        Data:{
          AutoDelHours: this.deviceform.AutoDelHours,
          LogSaveDays: this.deviceform.LogSaveDays * 1,
          // LastActTime: this.deviceform.LastActTime,
          // ...this.deviceform
        }
      }
      await connrequest('SetParamLogCfg', data1)
      if(res.Status.StatusCode === 0) {
        this.$message.success('保存成功')
        Cookies.set('Zhuoguan_DefaultLogDays', this.deviceform.default_log_days || 3)
        Cookies.set('Zhuoguan_DefaultPageLength', this.deviceform.page_length || 10)
        this.getData()
      }
    },
    // 获取子节点的校区
    async lazyLoad(node, resolve){
      if(node.level < 3){
        resolve(node.data) 
      }else{
        const data = {
          Paging:{
            QueryPageNo: 1,
            QueryPageLength: 100000
          },
          Filter:{
            SecondArea: node.label,
          }
        }
        const res = await connrequest('GetSchool', data)
        let arr = []
        res.Data.map(item => {
          arr.push( {SubClass: item.SchoolName, value: {SchoolID: item.SchoolID, SchoolName: item.SchoolName}, level: 4, children: undefined, leaf: true} )
        })
        resolve(arr) 
      }
    },
    async GetUpgradeRule(){
      const res = await connrequest('GetUpgradeRule')
      this.deviceform.UpgradeMode = res.Data.UpgradeMode
      if(res.Data.UpgradeMode != 1) 
      {
        let arr = []
        res.Data.Object.forEach(item=>{
          arr.push(item.SchoolName)
        })
        res.Data.Object = arr
      }
      let choseSchoolList = res.Data.UpgradeMode === 1 ? '' : res.Data.Object.join(',')
      this.$set(this.partition, 'Object', res.Data.Object)
      this.deviceform.choseSchoolList = choseSchoolList
    },
    async GetParamDictRole(){
      const res = await connrequest('GetParamDictRole')
      this.tableData = res.Data
    },
    addRole(){
      this.Action = 1
      this.$set(this.partition, 'Role', '')
      this.moderVisible = true
    },
    changeModer(row){
      this.Action = 2
      this.$set(this.partition, 'Role', row.Role)
      this.moderVisible = true
    },
    deleteModer(row){
      this.$confirm('删除角色前请先检查该角色是否存在改角色的资产和基于该角色配置策略规则。否则可能导致系统异常，请谨慎操作。确认要删除吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        const data = {
          Data: {
            Action: 3,
            Detail: {...row}
          }
        }
        const res = await connrequest('EditParamDictRole', data)
        if(res.Status.StatusCode === 0){
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
          this.GetParamDictRole()
        }
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });          
      });
    },
    async submitHomePage(){
      const data = {
        Data:{
          processDays: this.deviceform.processDays * 1,
          EventLogDays: this.deviceform.EventLogDays * 1,
          AutomaticRefreshInterval: this.deviceform.AutomaticRefreshInterval * 1,
          EventLogTotal: this.deviceform.EventLogTotal * 1,
          EventLevel: this.deviceform.EventLevel * 1,
        }
      }
      const res = await connrequest('SetFirstPageParam',data)
      if(res.Status.StatusCode === 0) {
        this.$message.success('保存成功')
        this.handleClick('首页参数')
      }
    },
    async submitRole(){
      if(!this.partition.Role){
        this.$message.error('角色名称不能为空')
        return false
      }
      if(this.tableData.findIndex(item => item.Role == this.partition.Role) !== -1){
        this.$message.error('该角色已经存在')
        return false
      }
      const data = {
        Data: {
          Action: this.Action,
          Detail: {...this.partition}
        }
      }
      const res = await connrequest('EditParamDictRole', data)
      if(res.Status.StatusCode === 0){
        this.$message.success(this.Action === 1 ? '新增成功' : '修改成功')
        this.moderVisible = false
        this.GetParamDictRole()
      }
    },
    async submitUpgradeRules(){
      if(this.deviceform.UpgradeMode === 2 && !this.deviceform.choseSchoolList){
        this.$message.error('请选择校区')
        return false
      }
      if(this.deviceform.UpgradeMode != 1)
      {
        var list = []
        this.partition.Object.forEach(item=>{
          let info = {"SchoolID":this.schoolMap.get(item),'SchoolName':item}
          list.push(info)
        })
        this.partition.Object  = list
      }
      const data = {
        Data:{
          UpgradeMode: this.deviceform.UpgradeMode,
          Object: this.deviceform.UpgradeMode === 1 ? [] : this.partition.Object
        }
      }
      const res = await connrequest('SetUpgradeRule', data)
      if(res.Status.StatusCode === 0){
        this.$message.success('保存成功')
        this.GetUpgradeRule()
      }
    },
    async choseSchool(){
      if(this.deviceform.choseSchoolList.length > 0){
        this.partition.Object = this.deviceform.choseSchoolList.split(',')
      }
      this.choseSchoolDialog = true
    },
    submitSchool(){
      if(!this.partition.Object || this.partition.Object.length === 0){
        this.$message.error('请选择校区')
        return false
      }
      this.$set(this.deviceform, 'choseSchoolList', this.partition.Object.join(','))
      this.choseSchoolDialog = false
    },
    async GetDeviceStatusSumTree() {
      const res = await connrequest('GetDeviceStatusSumTree')
      let partitionList = []
      let expandArray = []
      res.Data.PrimName = res.Data.RootName //因为后端返回的所有分区名字叫RootName，子菜单又叫PrimAreaName, 这里做个转换
      this.RootName = res.Data.RootName
      res.Data.disabled = true
      res.Data.edit = false
      res.Data.PrimArea.map(item => {
        item.edit = false
        partitionList.push(item)
        expandArray.push(res.Data.RootName, item.PrimAreaName)
      })
      let nodeData = [this.transformData(res.Data)]
      this.schoolMap = new Map()
      // this.schoolMap.set(item.SchoolName, item.SchoolID);
      // 遍历每个一级区域
      res.Data.PrimArea.forEach(primArea => {
          // 遍历每个二级区域
          primArea.SecondArea.forEach(secondArea => {
              // 遍历每个学校
              secondArea.School.forEach(school => {
                  // 将学校名称作为键，学校ID作为值存储在字典中
                  this.schoolMap.set(school.SchoolName, school.SchoolID);
              });
          });
      });
      return nodeData
    },
    transformData(inputData) {
      const { RootName, PrimArea} = inputData;
        return {
          SubClass: RootName,
          level: 1,
          children: PrimArea.map(area => ({
            SubClass: area.PrimAreaName,
            level: 2,
            children: area.SecondArea.map(secondArea => ({
              SubClass: secondArea.SecondAreaName,
              level: 3,
              children: secondArea.School.map(School => ({
                SubClass: School.SchoolName,
                value: School.SchoolName,
                level: 4,
              }))
          }))
        }))
      }
    },
    handleChange(row){
    }
  }
}
</script>
<style lang="scss" scoped>
/* @import url(); 引入css类 */
  .parameType-wrap{
    display:flex;
    flex-wrap: wrap;
  }
  ::v-deep.input-item{
    width: 1100px;
    margin-top: 10px;
    .parameType{
      border: 1px solid #eceff5;
      border-radius: 3px;
      width: 530px;
      padding: 10px;
      margin: 5px 10px 5px 0px;
      box-shadow: 0 0 10px #eceff5;
      .title{
        border-bottom: 1px solid #eceff5;
        padding-bottom : 10px;
      }
    }
    .el-form-item{
      margin-bottom: 6px;
    }
    .el-input-group__append, .el-input-group__prepend{
      width: 60px;
      padding: 0;
      text-align: center;
    }
  }
  .title{
    margin-bottom: 20px;
  }
  ::v-deep.el-form-item{
    label{
      font-weight: 500;
    }
  }
  /*  dialog*/
  .el-dialog__header {
    padding: 15px 20px 15px;
  }
  .el-dialog__headerbtn{
    top: 15px;
  }
  
  /* dialog header */
  .avue-crud__dialog__header {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
  }
  .el-dialog__title {
    color: rgba(0,0,0,.85);
    font-weight: 500;
    word-wrap: break-word;
  }
  .avue-crud__dialog__menu {
    padding-right: 35px;
    float: left;
  }
  .avue-crud__dialog__menu i {
    color: white;
    font-size: 15px;
  }
  .el-icon-full-screen{
    cursor: pointer;
  }
  .el-icon-full-screen:before {
    content: "\e719";
  }
  .el-icon-copy-document{
    cursor: pointer;
  }
</style>